/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.ce.entities;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Jarik
 */
@Entity
@Table(name = "officialbankrate")
@NamedQueries({
    @NamedQuery(name = "Officialbankrate.findAll", query = "SELECT o FROM Officialbankrate o"),
    @NamedQuery(name = "Officialbankrate.findById", query = "SELECT o FROM Officialbankrate o WHERE o.id = :id"),
    @NamedQuery(name = "Officialbankrate.findByRate", query = "SELECT o FROM Officialbankrate o WHERE o.rate = :rate"),
    @NamedQuery(name = "Officialbankrate.findByDate", query = "SELECT o FROM Officialbankrate o WHERE o.date = :date")})
public class Officialbankrate implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Rate")
    private double rate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "Date")
    @Temporal(TemporalType.TIMESTAMP)
    private Date date;
    @JoinColumn(name = "CurrencyTo", referencedColumnName = "ShortName")
    @ManyToOne(optional = false)
    private Currency currencyTo;
    @JoinColumn(name = "CurrencyFrom", referencedColumnName = "ShortName")
    @ManyToOne(optional = false)
    private Currency currencyFrom;

    public Officialbankrate() {
    }

    public Officialbankrate(Integer id) {
        this.id = id;
    }

    public Officialbankrate(Integer id, double rate, Date date) {
        this.id = id;
        this.rate = rate;
        this.date = date;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public double getRate() {
        return rate;
    }

    public void setRate(double rate) {
        this.rate = rate;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Currency getCurrencyTo() {
        return currencyTo;
    }

    public void setCurrencyTo(Currency currencyTo) {
        this.currencyTo = currencyTo;
    }

    public Currency getCurrencyFrom() {
        return currencyFrom;
    }

    public void setCurrencyFrom(Currency currencyFrom) {
        this.currencyFrom = currencyFrom;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Officialbankrate)) {
            return false;
        }
        Officialbankrate other = (Officialbankrate) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bionic.ce.entities.Officialbankrate[ id=" + id + " ]";
    }
    
}
